<script language="javascript" type="text/javascript"
	src="<?php echo $this->load->config->item('base_url') . $this->load->config->item('inc_folder'); ?>scripts/jquery-2.0.3.js"></script>
<script type="text/javascript">
	$(function() {  
        $('#tglawal').datepicker({
			dateFormat:'yy-mm-dd',
			buttonImage:'assets/images/calendar.gif',
			buttonImageOnly : true,
			showOn : 'button'
		});  
    });  
	
	$(function() {  
        $('#tglakhir').datepicker({
			dateFormat:'yy-mm-dd',
			buttonImage:'assets/images/calendar.gif',
			buttonImageOnly : true,
			showOn : 'button'
		});  
    });  
</script>


<h1><?php //echo $nama_perusahaan; ?></h1>
<h2><?php //echo $alamat_perusahaan; ?></h2>
    <div id="body">
        <?php
            //echo $bio;
            //echo $menu;
        ?>
        <div class="cleaner_h10"></div>
        <table align="center">
            <tr align="center">
                <td>
                    <?php
                        //echo $paginator;
                    ?>
                </td>
            </tr>
        </table>
		<div class="cleaner_h10"></div>
        <form method="post" name="frmSearch" action="<?php echo site_url('lapkwitansicontroller');?>">
		<table width="100%" cellpadding="3" cellspacing="0" border="1">
			<tr>
                <td width="90">Tanggal</td>
                <td>:</td>
                <td width="172"><input type="text"  name="tglawal" id="tglawal" maxlength="10" value="" style="width:110px;"/></td>
                <td width="30">S/D </td>
                <td width="542"><input type="text"  name="tglakhir" id="tglakhir" maxlength="10" value="" style="width:110px;"/></td>
            </tr>
            <tr>
            	<td width="90">Jenis Transaksi</td>
                <td width="9">:</td>
                <td colspan="3">
                    <select name="choose" id="choose">
                    <option value="B">Pembelian</option>
                    <option value="J">Penjualan</option>
                </select>
                </td>
            </tr>
			<tr valign="top" align="center">
            	<td>&nbsp;</td>
                <td colspan="5"><input type="submit" value="Search" name="btnview" ></td>
			</tr>
		</table>
        </form>
        <br />
      	<div class="cleaner_h10"></div>
        <?php
		if (isset($_POST['btnview']))
		{
			$pilih = trim($_POST['choose']);
			$tglawal = trim($_POST['tglawal']);
			$tglakhr = trim($_POST['tglakhir']);
		}else{
			$pilih = "";
			$tglawal = "";
			$tglakhr = "";
		}
		?>
        <form method="post" name="frmexcel" action="<?php echo site_url("lapkwitansicontroller/toExcel?choose=".$pilih."&tglawal=".$tglawal."&tglakhir=".$tglakhr."");?>">
        	<?php if ($pilih =="J"){?>
            <table border="1" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#CCCCCC">
                <tr style="background-color:#FFFFFF; color:#000000;" align="center">
                    <td colspan="12" height="25">Laporan Kwitansi</td>
                </tr>
                <tr style="background-color:#333; color:#FFFFFF;" align="center">
                    <td>No Kwitansi</td>
                    <td>Tanggal Kwitansi</td>
                    <td>No Faktur</td>
                    <td>Nama Pelanggan</td>                    
                    <td>Total Quantity</td>                    
                    <td>Total Amount</td>
                    <td>Type bayar</td>
                    <td>Bank Penerima</td>
                    <td>Bank Pelanggan</td>
                    <td>Rekening Pelanggan</td>
                    <td>Keterangan</td>
                    <td>Nama Pembuat</td>
                </tr>
                <?php
                    if(count($data)>0)
                    { 
                    	for($i = 0 ; $i < count($data); $i++){
                    		//var_dump($data[$i]);
                ?>                              
                <tr class="cellDefault">
                    <td><?php echo $data[$i]->nokwitansi;?></td>
					<td><?php echo $data[$i]->createdon;?></td>
                    <td><?php echo $data[$i]->nofaktur;?></td>
                    <td><?php if(isset($data[$i]->namapelanggan) && !empty($data[$i]->namapelanggan) && !($data[$i]->namapelanggan == '')) echo $data[$i]->namapelanggan; else echo $data[0]->namapelanggan;?></td>
                    <td><?php if(isset($data[$i]->TotalQuantity) && !empty($data[$i]->TotalQuantity) && !($data[$i]->TotalQuantity == '')) echo $data[$i]->TotalQuantity; else echo $data[0]->TotalQuantity;?></td>
                    <td><?php if(isset($data[$i]->totalamount) && !empty($data[$i]->totalamount) && !($data[$i]->totalamount == '')) echo $data[$i]->totalamount; else echo $data[0]->totalamount;?></td>
                    <td><?php if(isset($data[$i]->Typebayar) && !empty($data[$i]->Typebayar) && !($data[$i]->Typebayar == '')) echo $data[$i]->Typebayar; else echo $data[0]->Typebayar;?></td>
                    <td><?php if(isset($data[$i]->bankname) && !empty($data[$i]->bankname) && !($data[$i]->bankname == '')) echo $data[$i]->bankname; else echo "-";?></td>
                    <td><?php if(isset($data[$i]->Banknamepelanggan) && !empty($data[$i]->Banknamepelanggan) && !($data[$i]->Banknamepelanggan == '')) echo $data[$i]->Banknamepelanggan; else echo $data[0]->Banknamepelanggan;?></td>
                    <td><?php if(isset($data[$i]->NoRekeningpelanggan) && !empty($data[$i]->NoRekeningpelanggan) && !($data[$i]->NoRekeningpelanggan == '')) echo $data[$i]->NoRekeningpelanggan; else echo $data[0]->NoRekeningpelanggan;?></td>
                    <td><?php if(isset($data[$i]->Keterangan) && !empty($data[$i]->Keterangan) && !($data[$i]->Keterangan == '')) echo $data[$i]->Keterangan; else echo $data[0]->Keterangan;?></td>
                    <td><?php if(isset($data[$i]->CreatedBy) && !empty($data[$i]->CreatedBy) && !($data[$i]->CreatedBy == '')) echo $data[$i]->CreatedBy; else echo $data[0]->CreatedBy;?></td>
                </tr>                
                <?php 
                    	}
                    } 
                    else
                    {
                        echo "<tr>";
                        echo "<td colspan='9' style='text-align:center;color:red;'>No Data To Display</td>";
                        echo "</tr>";
                    } 
                ?>
            </table>
            <?php }else{ ?>
            <table border="1" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#CCCCCC">
                <tr style="background-color:#FFFFFF; color:#000000;" align="center">
                    <td colspan="7" height="25">Laporan Kwitansi</td>
                </tr>
                <tr style="background-color:#333; color:#FFFFFF;" align="center">
                    <td>No Kwitansi</td>
                    <td>Tanggal Kwitansi</td>
                    <td>Total Quantity</td>
                    <td>Type bayar</td>
                    <td>Total Amount</td>
                    <td>Keterangan</td>
                    <td>Nama Pembuat</td>
                </tr>
                <?php 
                    if(count($data)>0)
                    { 
                ?>
                {data}
                <tr class="cellDefault">
                    <td>{NoKwitansi}</td>
					<td>{CreatedOn}</td>
                    <td>{TotalQuantity}</td>
                    <td>{Typebayar}</td>
                    <td>{TotalAmount}</td>
                    <td>{Keterangan}</td>
                    <td>{CreatedBy}</td>
                </tr>
                {/data}
                <?php 
                    } 
                    else
                    {
                        echo "<tr>";
                        echo "<td colspan='9' style='text-align:center;color:red;'>No Data To Display</td>";
                        echo "</tr>";
                    } 
                ?>
            </table>
            <?php } ?>
            <table border="1" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#CCCCCC">
                <tr align="center">
                    <td colspan="7">
                        <input type="submit" name="btntoxl" value="Export" />&nbsp;<input type="button" name="btnClose" value="Back" class="btn" onclick="javascript:window.location='<?php echo site_url('menuhomecontroller'); ?>';" />
                    </td>
                </tr>
            </table>
      	</form>
    	<div class="cleaner_h10"></div>
		<table align="center">
			<tr align="center">
				<td>
					<?php
						//echo $paginator;
					?>
				</td>
			</tr>
		</table>
	</div>
